package com.lantian.uavmaterial.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.lantian.uavmaterial.domain.UavPropulsionSystem;
import com.lantian.uavmaterial.service.IUavPropulsionSystemService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lantian.common.annotation.Log;
import com.lantian.common.core.controller.BaseController;
import com.lantian.common.core.domain.AjaxResult;
import com.lantian.common.enums.BusinessType;

import com.lantian.common.utils.poi.ExcelUtil;
import com.lantian.common.core.page.TableDataInfo;

/**
 * 动力系统Controller
 * 
 * @author lantian
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/uav/propulsion")
public class UavPropulsionSystemController extends BaseController
{
    @Autowired
    private IUavPropulsionSystemService uavPropulsionSystemService;

    /**
     * 查询动力系统列表
     */
    @PreAuthorize("@ss.hasPermi('uav:propulsion:list')")
    @GetMapping("/list")
    public TableDataInfo list(UavPropulsionSystem uavPropulsionSystem)
    {
        startPage();
        List<UavPropulsionSystem> list = uavPropulsionSystemService.selectUavPropulsionSystemList(uavPropulsionSystem);
        return getDataTable(list);
    }

    /**
     * 导出动力系统列表
     */
    @PreAuthorize("@ss.hasPermi('uav:propulsion:export')")
    @Log(title = "动力系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UavPropulsionSystem uavPropulsionSystem)
    {
        List<UavPropulsionSystem> list = uavPropulsionSystemService.selectUavPropulsionSystemList(uavPropulsionSystem);
        ExcelUtil<UavPropulsionSystem> util = new ExcelUtil<UavPropulsionSystem>(UavPropulsionSystem.class);
        util.exportExcel(response, list, "动力系统数据");
    }

    /**
     * 获取动力系统详细信息
     */
    @PreAuthorize("@ss.hasPermi('uav:propulsion:query')")
    @GetMapping(value = "/{flightPowerSystemId}")
    public AjaxResult getInfo(@PathVariable("flightPowerSystemId") String flightPowerSystemId)
    {
        return success(uavPropulsionSystemService.selectUavPropulsionSystemByFlightPowerSystemId(flightPowerSystemId));
    }

    /**
     * 新增动力系统
     */
    @PreAuthorize("@ss.hasPermi('uav:propulsion:add')")
    @Log(title = "动力系统", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UavPropulsionSystem uavPropulsionSystem)
    {
        return toAjax(uavPropulsionSystemService.insertUavPropulsionSystem(uavPropulsionSystem));
    }

    /**
     * 修改动力系统
     */
    @PreAuthorize("@ss.hasPermi('uav:propulsion:edit')")
    @Log(title = "动力系统", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UavPropulsionSystem uavPropulsionSystem)
    {
        return toAjax(uavPropulsionSystemService.updateUavPropulsionSystem(uavPropulsionSystem));
    }

    /**
     * 删除动力系统
     */
    @PreAuthorize("@ss.hasPermi('uav:propulsion:remove')")
    @Log(title = "动力系统", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flightPowerSystemIds}")
    public AjaxResult remove(@PathVariable String[] flightPowerSystemIds)
    {
        return toAjax(uavPropulsionSystemService.deleteUavPropulsionSystemByFlightPowerSystemIds(flightPowerSystemIds));
    }
}
